var room2d = {};

//create folder object
room2d.events = {};
room2d.layout = {};
room2d.util = {};
room2d.view = {};
room2d.view.component = {};
room2d.view.component.charts = {};
room2d.view.elements = {};
room2d.view.elements.plugins = {};
room2d.view.elements.plugins.nodes = {};

//sava folder object
var folders = [];
function saveFolders(obj) {
    for(var key in obj) {
        folders.push(obj[key]);
        saveFolders(obj[key]);
    }
}
saveFolders(room2d);

//import js files
room2d.app = require("./app");
room2d.biz = require("./biz");
room2d.events.evEvent = require("./events/evEvent");
room2d.sceneConst = require("./sceneConst");
room2d.view.component.charts.room = require("./view/component/charts/room");
room2d.view.component.loading = require("./view/component/loading");
room2d.view.elements.plugins.nodes.jiguiNode = require("./view/elements/plugins/nodes/jiguiNode");
room2d.view.elements.plugins.nodes.rect = require("./view/elements/plugins/nodes/rect");

//call struct function
function callStruct(obj) {
    for(var key in obj) {
        var value = obj[key];
        if(value instanceof Function && value.hasOwnProperty('struct')) {
            value.struct(room2d);
        } else if(folders.indexOf(value) !== -1) {
            callStruct(value);
        }
    }
}
callStruct(room2d);

module.exports = room2d;